# Contributor: Corentin Henry <corentinhenry@gmail.com>
# Maintainer:
pkgname=ostinato
pkgver=1.1
pkgrel=7
pkgdesc="Packet/Traffic Generator and Analyzer"
url="https://www.ostinato.org"
arch="all"
license="GPL-3.0-or-later"
options="!check" # make test does nothing
makedepends="libnl3-dev libpcap-dev protobuf-dev qt5-qtbase-dev
	qt5-qtscript-dev qt5-qtsvg-dev"
subpackages="$pkgname-drone $pkgname-gui"
source="$pkgname-$pkgver.tar.gz::https://github.com/pstavirs/ostinato/archive/v$pkgver.tar.gz
	ModelTest.patch
	"
	# ModelTest::ModelTest is included and needed during linking even in release mode

build() {
	qmake-qt5 PREFIX=/usr

	# qmake generates broken CFLAGS, demand it use ours
	# also keep DEFINES because of #11848
	# j1 because there is no correct dependency ordering for a proto header
	make -j1 CXXFLAGS="$CXXFLAGS \$(DEFINES)"
}

package() {
	make INSTALL_ROOT="$pkgdir" install
}

drone() {
	pkgdesc="ostinato controller"

	install -d "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/drone "$subpkgdir"/usr/bin/drone
}

gui() {
	pkgdesc="graphical controller for ostinato"
	depends="qt5-qtsvg" # 11849

	install -d "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/ostinato "$subpkgdir"/usr/bin/ostinato
}

sha512sums="
a45e157d155d4f2efe9a1594a140647b5cbd7264985b15a9ed47d86198c9df9d763170097dcfd40fae1317206e53c9155f08c48c747cce458e0cae7f3a841449  ostinato-1.1.tar.gz
e0a3d2781c62b1898a80af8522b36d6b1a7aeae9831c33c42e4e76fe002ee7ebff50d432508a18046d7b5988f09d9a9f90a0433cfae1d2c1cbeaf664671abf6c  ModelTest.patch
"
